home *** CD-ROM | disk | FTP | other *** search
/ Revista do CD-ROM 100 / CD-ROM 100.iso / aplic / oo1_1 / f_0328 / scalc.jar / text / scalc / guide / userdefined_function.xml < prev    next >
Encoding:
Extensible Markup Language  |  2003-04-30  |  8.5 KB  |  96 lines

  1. <?xml version="1.0" encoding="utf-8"?>
  2. <html><head><title>Defining Functions Yourself</title><meta name="filename" content="text/scalc/guide/userdefined_function"/><help:css-file-link xmlns:help="http://openoffice.org/2000/help"/><!--The CSS style header method for setting styles--><style type="text/css">
  3.  
  4.         table.Tabelle1{
  5.                 }
  6.         span.Tabelle1A{
  7.                 width:18cm;}
  8.         td.Tabelle1A1{
  9.                 }
  10.         p.P1{
  11.                 }
  12.         p.P2{
  13.                 }
  14.         p.P3{
  15.                 }
  16.         p.P4{
  17.                 }
  18.         p.P5{
  19.                 }
  20.         span.T1{
  21.                 font-weight:bold;}
  22.         span.fr1{
  23.                 }
  24.         </style></head><body>
  25.   
  26.   
  27.   <p class="P1"/>
  28.   <p class="Head1"><help:paragraphinfo state="U" number="1" xmlns:help="http://openoffice.org/2000/help"/><help:key-word value="functions; user-defined" tag="kw68166_1" xmlns:help="http://openoffice.org/2000/help"/><help:key-word value="user-defined functions" tag="kw68166_4" xmlns:help="http://openoffice.org/2000/help"/><help:key-word value="Basic IDE; applying" tag="kw68166_3" xmlns:help="http://openoffice.org/2000/help"/><help:key-word value="IDE; Basic IDE" tag="kw68166_2" xmlns:help="http://openoffice.org/2000/help"/><help:to-be-embedded Eid="userdefined_function" xmlns:help="http://openoffice.org/2000/help"><help:link Id="68166">Defining Functions Yourself</help:link></help:to-be-embedded></p>
  29.   <p class="Paragraph"><help:paragraphinfo state="U" number="2" xmlns:help="http://openoffice.org/2000/help"/>You can apply user-defined functions in <help:productname xmlns:help="http://openoffice.org/2000/help">%PRODUCTNAME</help:productname> Calc in the following ways:</p>
  30.   <ul class="L1">
  31.    <li class="">
  32.     <p class="P2"><help:paragraphinfo state="U" number="3" xmlns:help="http://openoffice.org/2000/help"/>In the <help:productname xmlns:help="http://openoffice.org/2000/help">%PRODUCTNAME</help:productname> Help you will find information about programming the functions as <help:link Id="66872" xmlns:help="http://openoffice.org/2000/help">add-ins</help:link>. This method requires advanced knowledge of programming.</p>
  33.    </li>
  34.    <li class="">
  35.     <p class="P2"><help:paragraphinfo state="U" number="4" xmlns:help="http://openoffice.org/2000/help"/>Using the Basic-IDE, even without advanced knowledge of programming, you can define your own functions.</p>
  36.    </li>
  37.   </ul>
  38.   <p class="Paragraph"><help:paragraphinfo state="U" number="5" xmlns:help="http://openoffice.org/2000/help"/>In this example we define a VOL(a; b; c) function which calculates the volume of a rectangular solid with side lengths a, b and c.</p>
  39.   <p class="Head2"><help:paragraphinfo state="U" number="6" xmlns:help="http://openoffice.org/2000/help"/>Defining Your Own Functions in Basic IDE</p>
  40.   <table><tr class=""><td class="Tabelle1A1" style="text-align:left;"><span class="Tabelle1A">
  41.      <p class="TextInTable"><draw:image draw:name="Info0" svg:desc="Overview Basic IDE with macro" svg:pixelx="484" svg:pixely="324" svg:width="12.801cm" svg:height="8.578cm" xlink:href="67342" draw:filter-name="" xmlns:draw="http://openoffice.org/2000/drawing" xmlns:svg="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink"/></p>
  42.  
  43.     </span></td></tr></table>
  44.   <ol class="L2">
  45.    <li class="">
  46.     <p class="P3"><help:paragraphinfo state="U" number="7" xmlns:help="http://openoffice.org/2000/help"/>Choose <span class="T1">Tools - Macros - Macro</span>. The <span class="T1">Macro</span> dialog appears.</p>
  47.    </li>
  48.    <li class="">
  49.     <p class="P3"><help:paragraphinfo state="U" number="8" xmlns:help="http://openoffice.org/2000/help"/>Click the <span class="T1">Edit</span> button. You will now see the Basic IDE.</p>
  50.    </li>
  51.    <li class="">
  52.     <p class="P3"><help:paragraphinfo state="U" number="9" xmlns:help="http://openoffice.org/2000/help"/>Enter the function, as displayed in the illustration.</p>
  53.    </li>
  54.    <li class="">
  55.     <p class="P3"><help:paragraphinfo state="U" number="10" xmlns:help="http://openoffice.org/2000/help"/>Close the Basic-IDE window.</p>
  56.     <p class="P3"><help:paragraphinfo state="U" number="11" xmlns:help="http://openoffice.org/2000/help"/>Your function is automatically saved in the default module and is now available in your <help:productname xmlns:help="http://openoffice.org/2000/help">%PRODUCTNAME</help:productname>. If you apply the function in a Calc document that is to be used on another computer, you can copy the function to the Calc document. You will find the instructions in the following section.</p>
  57.    </li>
  58.   </ol>
  59.   <p class="Head2"><help:paragraphinfo state="U" number="18" xmlns:help="http://openoffice.org/2000/help"/>Copying user-defined functions to a document</p>
  60.   <p class="Paragraph"><help:paragraphinfo state="U" number="19" xmlns:help="http://openoffice.org/2000/help"/>In stage 2 of "Defining a user-defined function in Basic-IDE", in the <span class="T1">Macro</span> dialog you clicked on <span class="T1">Edit </span>. As the default, in the <span class="T1">Macro from</span> field the <span class="T1">soffice - Default - Module1</span> module is selected. The default module resides locally in your user directory.</p>
  61.   <p class="Paragraph"><help:paragraphinfo state="U" number="20" xmlns:help="http://openoffice.org/2000/help"/>If you want to copy the user-defined function to a Calc document:</p>
  62.   <ol class="L3">
  63.    <li class="">
  64.     <p class="P4"><help:paragraphinfo state="U" number="21" xmlns:help="http://openoffice.org/2000/help"/>Choose <span class="T1">Tools - Macros - Macro</span>.</p>
  65.    </li>
  66.    <li class="">
  67.     <p class="P4"><help:paragraphinfo state="U" number="22" xmlns:help="http://openoffice.org/2000/help"/>In the <span class="T1">Macro from</span> field select <span class="T1">soffice - Default - Module1</span>. Click <span class="T1">Edit</span>.</p>
  68.    </li>
  69.    <li class="">
  70.     <p class="P4"><help:paragraphinfo state="U" number="23" xmlns:help="http://openoffice.org/2000/help"/>In the Basic-IDE, select the source of your user-defined function and copy it to the clipboard. Close the Basic-IDE.</p>
  71.    </li>
  72.    <li class="">
  73.     <p class="P4"><help:paragraphinfo state="U" number="24" xmlns:help="http://openoffice.org/2000/help"/>Choose <span class="T1">Tools - Macros - Macro</span>.</p>
  74.    </li>
  75.    <li class="">
  76.     <p class="P4"><help:paragraphinfo state="U" number="25" xmlns:help="http://openoffice.org/2000/help"/>In the <span class="T1">Macro from</span> field select <span class="T1">(Name of the Calc document)- Default - Module1</span>. Click <span class="T1">Edit</span>.</p>
  77.    </li>
  78.    <li class="">
  79.     <p class="P4"><help:paragraphinfo state="U" number="26" xmlns:help="http://openoffice.org/2000/help"/>Paste the clipboard contents in the Basic-IDE of the document.</p>
  80.    </li>
  81.   </ol>
  82.   <p class="Head2"><help:paragraphinfo state="U" number="12" xmlns:help="http://openoffice.org/2000/help"/>Applying a user-defined function in <help:productname xmlns:help="http://openoffice.org/2000/help">%PRODUCTNAME</help:productname> Calc</p>
  83.   <p class="Paragraph"><help:paragraphinfo state="U" number="13" xmlns:help="http://openoffice.org/2000/help"/>Once you have defined the function VOL(a; b; c) in the Basic-IDE, you can apply it in exactly the same way as the built-in functions of <help:productname xmlns:help="http://openoffice.org/2000/help">%PRODUCTNAME</help:productname> Calc.</p>
  84.   <ol class="L4">
  85.    <li class="">
  86.     <p class="P5"><help:paragraphinfo state="U" number="14" xmlns:help="http://openoffice.org/2000/help"/>Open a <help:productname xmlns:help="http://openoffice.org/2000/help">%PRODUCTNAME</help:productname> Calc document and enter a few numbers in columns A, B and C, for example.</p>
  87.    </li>
  88.    <li class="">
  89.     <p class="P5"><help:paragraphinfo state="U" number="15" xmlns:help="http://openoffice.org/2000/help"/>Set the cursor in cell D1 and enter the following:</p>
  90.     <p class="P5"><help:paragraphinfo state="U" number="16" xmlns:help="http://openoffice.org/2000/help"/>=VOL(A1;B1;C1)</p>
  91.     <p class="P5"><help:paragraphinfo state="U" number="17" xmlns:help="http://openoffice.org/2000/help"/>The function is evaluated and you will see the result in cell D1.</p>
  92.    </li>
  93.   </ol>
  94.   <p class="ParaList"><help:paragraphinfo state="S" xmlns:help="http://openoffice.org/2000/help"/><help:embedded Id="65598" Eid="related" xmlns:help="http://openoffice.org/2000/help"/></p>
  95.   <p class="ParaList"><help:paragraphinfo state="U" number="27" xmlns:help="http://openoffice.org/2000/help"/>Switch to "Help about <help:productname xmlns:help="http://openoffice.org/2000/help">%PRODUCTNAME</help:productname> Basic", then search for "Integrated Development Environment (IDE)".</p>
  96.  </body></html>